import request, { uploadRequest } from './request';
import type {
  UploadImageBodyType,
  Login,
  Common,
  Index,
  Active,
  Information,
  My,
  SignTeam,
  UserSign,
  Interaction,
  UserAddr,
  Match,
  Coupon,
  SingleSign,
  WxPayInfo,
  Coze,
} from './data';

/**
 * 公共接口
 * Common | Login
 */

// 授权手机号登录
export const mobile_login = (data: Login.MobileLogin.Body) =>
  request<Login.MobileLogin.Data>('/login/mobile_login', 'POST', data);
// 微信登录
export const wx_login = (data: Login.WxLogin.Body) => request<Login.WxLogin.Data>('/login/wx_login', 'POST', data);
// 发送短息
export const send_sms = (data: Login.SendSms.Body) => request<null>('/common/send_sms', 'POST', data);
// 手机验证码登录
export const sms_login = (data: Login.SmsLogin.Body) => request<Login.SmsLogin.Data>('/login/sms_login', 'POST', data);
// 退出登录
export const logout = () => request<null>('/login/logout', 'POST');
// 获取底部图标
export const bottom_icon = () => request<Common.BottomIcon.Data>('/common/icon', 'GET');
// 上传图片
export const uploadImage = (data: UploadImageBodyType) =>
  uploadRequest<{ url: string }>('/common/upload', data.filePath, data?.formData);
// 校验身份证图片
export const check_ocr_identity = (data: Common.CheckOcrIdentity.Body) =>
  request<Common.CheckOcrIdentity.Data>('/common/check_ocr_identity', 'POST', data);
// 获取全局配置
export const commonConfig = () => request<Common.Config.Data>('/common/config', 'GET');

/**
 * 首页
 * Index
 */

//  首页
export const index = () => request<Index.Home.Data>('/index/index', 'GET');
// 精彩瞬间
export const moments = (query: ReqPages) => request<ResPages<Index.Moments.Data[]>>('/moments/index', 'GET', query);
// 精彩瞬间 - 锦集
export const momentsDetail = (query: ReqPages & { id: number }) =>
  request<ResPages<string[]>>('/moments/detail', 'GET', query);
// 海报壁纸
export const poster = (data: { poster_id: string }) => request<string>('/index/poster', 'GET', data);

/**
 * 活动
 * Active
 */

// 活动列表
export const activeIndex = (data: Active.Index.Query & ReqPages) =>
  request<ResPages<Active.Index.Data[]>>('/active/index', 'GET', data);
// 活动详情
export const activeDetail = (data: Active.Detail.Query) => request<Active.Detail.Data>('/active/detail', 'GET', data);
// 材料下载
export const activeFileList = (data: Active.Detail.Query) => request<Active.File.Data[]>('/active/file', 'GET', data);
// 分组下拉
export const activeGroup = (data: Active.Detail.Query) => request<Active.Group.Data[]>('/active/group', 'GET', data);
// 发布到组队大厅
export const activeLaunchTeamHall = (data: Pick<SignTeam.MemberList.Body, 'sign_team_id'> & { remark: string }) =>
  request<null>('/active/launch_team_hall', 'POST', data);
// 活动报名字段列表
export const getActiveField = (data: Active.Detail.Query) =>
  request<Active.Detail.Field[]>('/active/get_active_field', 'GET', data);
// 通过组别查衣服尺码列表
export const getActiveSizeList = (data: Active.Size.Query) =>
  request<Active.Size.Data[]>('/active/get_active_size', 'GET', data);
// 客服
export const getActiveKefu = (data: Active.Detail.Query) => request<Active.Size.Data[]>('/active/kefu', 'GET', data);

/**
 * 资讯
 * Information
 */

// 资讯列表
export const newsIndex = (query: ReqPages) =>
  request<ResPages<Information.Index.Data[]>>('/information/index', 'GET', query);
// 资讯详情
export const newsDetail = (query: Information.Detail.Query) =>
  request<Information.Detail.Data>('/information/detail', 'GET', query);
// 资讯收藏点赞
export const newsCollect = (data: Interaction.Collect.Body) =>
  request<Information.Detail.Data>('/information/collect', 'POST', data);
// 发表评论
export const newsReview = (data: Interaction.Review.Add.Body) => request<null>('/information/review', 'POST', data);
// 评论列表
export const newsReviewList = (query: { information_id: number } & ReqPages) =>
  request<ResPages<Interaction.Review.List.Data[]>>('/information/review_list', 'GET', query);
// 删除评论
export const newsDelReview = (query: { review_id: string }) => request<string>('/information/del_review', 'GET', query);
// 举报
export const report = (data: Partial<Information.Report.Body>) => request<string>('/information/report', 'POST', data);
// 举报类型
export const reasontype = () => request<string[]>('/information/reasontype', 'POST');

/**
 * 我的
 * My
 */

// 我的信息
export const myIndex = () => request<My.Index.Data>('/my/index', 'GET');
// 修改个人信息
export const myUpdateInfo = (data: My.UpdateInfo.Body) => request<string>('/my/update_info', 'POST', data);
// 报名券
export const signUpTicket = (query: ReqPages) =>
  request<ResPages<My.Coupon.Data[]>>('/my/sign_up_ticket', 'GET', query);
// 抽奖券
export const raffleTicket = (query: ReqPages) => request<ResPages<My.Coupon.Data[]>>('/my/raffle_ticket', 'GET', query);
// 奖品券
export const goodsTicket = (query: ReqPages) => request<ResPages<My.Coupon.Data[]>>('/my/goods_ticket', 'GET', query);
// 奖品券详情
export const goodsCouponDetail = (data: { coupon_code: string }) =>
  request<My.Coupon.DetailData>('/prize/goods_coupon_detail', 'POST', data);
// 奖品券核销奖品
export const goodsCouponCheck = (data: { coupon_code: string; id: string }) =>
  request<string>('/prize/goods_coupon_check', 'POST', data);
// 抽奖奖品列表
export const prizelist = (data: { coupon_id: string }) =>
  request<Coupon.Prize.Data[]>('/prize/prizelist', 'POST', data);
// 抽奖
export const prizeRaffle = (data: { coupon_id: string }) => request<Coupon.Prize.Data>('/prize/raffle', 'POST', data);
// 抽奖记录
export const prizeRecord = (data: ReqPages) => request<ResPages<Coupon.Record.Data[]>>('/prize/record', 'GET', data);
// 核销记录
export const prizeCheckRecord = (data: ReqPages) =>
  request<ResPages<Coupon.Record.Data[]>>('/prize/prize_check_record', 'GET', data);
// 商品列表
export const goodsList = (query: ReqPages & { coupon_id: number }) =>
  request<ResPages<My.Coupon.Shop.Data[]>>('/my/goods_list', 'GET', query);
// 关于我们
export const aboutUs = () => request<My.AboutUs.Data>('/my/about_us', 'GET');
// 我的活动
export const myActive = (query: My.Active.Query) => request<ResPages<My.Active.Data[]>>('/my/active', 'GET', query);
// 我的互动
export const myInteraction = (query: My.Interaction.Query & ReqPages) =>
  request<ResPages<Interaction.Hall.Data[]>>('/my/interaction', 'GET', query);
// 商城订单
export const myOrder = (query: { title?: string } & ReqPages) =>
  request<ResPages<Interaction.Hall.Data[]>>('/my/order', 'GET', query);
// 我的积分明细
export const myScoreInfo = () => request<My.Score.Info.Data>('/my/score', 'GET');
// 扫码积分页面
export const scoreCheckDetail = (data: { qr_data: My.Score.Info.Data['qr_data'] }) =>
  request<any>('/my/score_check_detail', 'GET', data);
// 积分记录
export const scoreRecord = (data: ReqPages) =>
  request<ResPages<My.Score.Record.Data[]>>('/my/score_record', 'GET', data);
// 扫码积分抵扣
export const scoreDeduct = (data: My.Score.Deduct.Body) => request<string>('/my/score_deduct', 'POST', data);
// 工作人员抵扣积分记录
export const scoreCheckRecord = (data: ReqPages) =>
  request<ResPages<My.Score.Check.Record.Data[]>>('/my/score_check_record', 'GET', data);
// 工作人员抵扣详情
export const scoreRecordDetail = (data: { record_id: string }) =>
  request<My.Score.Check.Record.Data>('/my/score_record_detail', 'GET', data);
// 撤销积分抵扣
export const cancelScoreRecord = (data: { record_id: string }) =>
  request<string>('/my/cancel_score_record', 'POST', data);

/**
 * 报名
 * Sign
 */

// 检测登录
export const signCheckLogin = () => request<null>('/sign_team/check_login', 'POST');
// 队长报名
export const signTeamLeader = (data: SignTeam.Leader.Body) =>
  request<SignTeam.Leader.Data>('/sign_team/header', 'POST', data);
// 队员报名
export const signTeamMember = (data: Pick<SignTeam.Leader.Body, 'members' | 'active_id'> & { invite_code: string }) =>
  request<SignTeam.Leader.Data>('/sign_team/member', 'POST', data);
// 修改报名信息
export const signTeamUpdateInfo = (data: SignTeam.UpdateInfo.Body) =>
  request<null>('/sign_team/update_info', 'POST', data);
// 队伍详情
export const signTeamDetail = (data: SignTeam.Detail.Body) =>
  request<Omit<SignTeam.Leader.Body, 'members'> & SignTeam.Detail.Data>('/sign_team/detail', 'GET', data);
// 删除报名人绑定的成员
export const signTeamDelMember = (data: { sign_id: string }) => request<null>('/sign_team/del_member', 'POST', data);
// 队员管理列表
export const signTeamMemberList = (data: SignTeam.MemberList.Body) =>
  request<SignTeam.MemberList.Data[]>('/sign_team/member_list', 'GET', data);
// 移除队员
export const signTeamMemberRemove = (data: { sign_id: number }) =>
  request<null>('/sign_team/remove_member', 'POST', data);
// 更换队长
export const signTeamMemberChangeHeader = (data: { sign_id: number }) =>
  request<null>('/sign_team/change_header', 'POST', data);
// 队员申请退赛
export const signTeamApplyQuit = (data: { sign_id: number }) => request<null>('/sign_team/apply_quit', 'POST', data);
// 队伍解散
export const signTeamRemove = (data: Pick<SignTeam.MemberList.Body, 'sign_team_id'>) =>
  request<null>('/sign_team/remove', 'POST', data);
// 队伍信息
export const getTeamInfo = (query: Partial<SignTeam.Info.Query>) =>
  request<SignTeam.Info.Data>('/sign_team/get_team_info', 'GET', query);
// 队伍分享
export const signTeamShare = (data: { sign_team_id: string }) => request<string>('/sign_team/share', 'POST', data);
// 队伍提交
export const signTeamSubmit = (data: { sign_team_id: string }) => request<string>('/sign_team/submit', 'POST', data);
// 取消提交队伍
export const signTeamCancelSubmit = (data: { sign_team_id: string }) =>
  request<string>('/sign_team/team_cancel', 'POST', data);
// 尺码列表
export const signTeamSizeList = (data: Pick<SignTeam.ChooseSize.Body, 'active_id'>) =>
  request<SignTeam.SizeSignList.Data>('/sign_team/size_list', 'GET', data);
// 提交选择的尺码及装备包领取方式
export const signTeamChooseSize = (data: SignTeam.ChooseSize.Body) =>
  request<SignTeam.ChooseSize.Data>('/sign_team/choose_size', 'POST', data);
// 尺码信息
export const signTeamSizeInfo = (data: Pick<SignTeam.ChooseSize.Body, 'active_id'>) =>
  request<SignTeam.SizeInfo.Data>('/sign_team/size_info', 'GET', data);
// 支付
export const signTeamPay = (data: SignTeam.Pay.Body) => request<SignTeam.Pay.Data>('/sign_team/pay', 'POST', data);
// 取消支付
export const signTeamPayCancel = (data: Omit<SignTeam.Pay.Body, 'wx_code'>) =>
  request<SignTeam.Pay.Data>('/sign_team/pay_cancel', 'POST', data);
// 关闭支付
export const signTeamPayClose = (data: { order_id: string }) => request<string>('/sign_team/pay_close', 'POST', data);
// 申请退赛(报名)
export const apply_compete = (data: { sign_id: string }) => request<string>('/sign_team/apply_compete', 'POST', data);
// 申请退赛(选择尺码)
export const apply_refund = (data: { active_id: string }) => request<string>('/sign_team/apply_refund', 'POST', data);

// 报名配置
export const userSignConfig = () => request<UserSign.Config.Data>('/user_sign/config', 'GET');
// 报名人列表
export const userSignIndex = () => request<UserSign.Index.Data[]>('/user_sign/index', 'GET');
// 报名人添加
export const userSignAdd = (data: Omit<SignTeam.Leader.Body, 'active_id' | 'title'>) =>
  request<UserSign.Config.Data[]>('/user_sign/add', 'POST', data);
// 报名人编辑
export const userSignEdit = (data: Omit<SignTeam.Leader.Body, 'active_id' | 'title'> & { id: number }) =>
  request<UserSign.Config.Data[]>('/user_sign/edit', 'POST', data);
// 报名人删除
export const userSignDel = (data: { id: number }) => request<UserSign.Config.Data[]>('/user_sign/del', 'POST', data);

// 单人报名
export const singleSign = (data: SingleSign.Submit.Body) => request<null>('/single_sign/submit', 'POST', data);

/**
 * 互动
 * Interaction
 */
// 组队大厅
export const interactionHall = (query: Interaction.Hall.Query & ReqPages) =>
  request<ResPages<Interaction.Hall.Data[]>>('/interaction/hall', 'GET', query);
// 组队大厅分组列表
export const interactionActiveGroup = (query: Partial<{ active_id: string }>) =>
  request<ResPages<Record<string, string>>>('/interaction/active_group', 'GET', query);
// 组队大厅队伍列表
export const interactionMemberList = (query: Partial<{ sign_team_id: string }>) =>
  request<ResPages<Interaction.MemberList.Data[]>>('/interaction/member_list', 'GET', query);
// 互动列表
export const interactionIndex = (query: Interaction.Index.Query & ReqPages) =>
  request<ResPages<Interaction.Index.Data[]>>('/interaction/index', 'GET', query);
// 互动详情
export const interactionDetail = (query: Information.Detail.Query) =>
  request<Interaction.Index.Data>('/interaction/detail', 'GET', query);
// 发布互动
export const interactionCreate = (data: Interaction.Create.Body) =>
  request<Interaction.Index.Data>('/interaction/create', 'POST', data);
// 收藏 | 点赞
export const interactionCollect = (data: Interaction.Collect.Body) =>
  request<null>('/interaction/collect', 'POST', data);
// 发表评论
export const interactionReview = (data: Interaction.Review.Add.Body) =>
  request<null>('/interaction/review', 'POST', data);
// 评论列表
export const interactionReviewList = (query: Interaction.Review.List.Body) =>
  request<ResPages<Interaction.Review.List.Data[]>>('/interaction/review_list', 'GET', query);
// 删除评论
export const interactionDelReview = (query: { review_id: string }) =>
  request<string>('/interaction/del_review', 'GET', query);

/**
 * 收货地址
 * UserAddr
 */
// 收货地址列表
export const userAddrList = (query: ReqPages) =>
  request<ResPages<UserAddr.List.Data[]>>('/user_addr/index', 'GET', query);
// 收货地址新增
export const userAddrAdd = (data: UserAddr.Add.Body) => request<null>('/user_addr/add', 'POST', data);
// 收货地址编辑
export const userAddrEdit = (data: UserAddr.Add.Body & { id: number }) =>
  request<null>('/user_addr/edit', 'POST', data);
// 收货地址删除
export const userAddrDel = (data: { id: number }) => request<null>('/user_addr/del', 'POST', data);

/**
 * 比赛相关
 * Match
 */
// 打卡点列表
export const matchPoint = (query: { active_id: string }) =>
  request<Match.Point.PointObj>('/compete/point', 'GET', query);
// 地图点列表
export const matchMapPoint = (query: { active_id: string }) =>
  request<Match.Map.Data>('/compete/map_point', 'GET', query);
// 二维码点位打卡
export const matchScanCodeCheck = (query: { point_id: string }) =>
  request<Match.Check.ScanCode.Data>('/compete/ewm_point_info', 'GET', query);
// 图片点位打卡
export const matchUploadImgCheck = (query: { point_id: string }) =>
  request<Match.Check.UploadImage.Data>('/compete/pic_point_info', 'GET', query);
// 上传图片打卡检测
export const matchSubmitPicCheck = (data: { point_id: string; img: string }) =>
  request<string>('/compete/submit_pic_check', 'POST', data);
// 上传图片人工打卡
export const matchSubmitPicManualCheck = (data: { point_id: string; img: string }) =>
  request<string>('/compete/submit_pic_manual_check', 'POST', data);
// 志愿者扫码打卡确认信息
export const matchScanCodeDetail = (query: Partial<Match.ScanCode.Detail.Body>) =>
  request<Match.ScanCode.Detail.Data>('/compete/scan_code_detail', 'GET', query);
// 志愿者扫码打卡确认
export const matchScanCodeDetailSubmit = (data: Partial<Omit<Match.ScanCode.Detail.Body, 'type'>>) =>
  request<string>('/compete/scan_code_check', 'POST', data);
// 志愿者扫码补给核销
export const matchScanCodeSupplySubmit = (data: Partial<Omit<Match.ScanCode.Detail.Body, 'type'>>) =>
  request<string>('/compete/scan_supply_check', 'POST', data);
// 用户扫码打卡确认
export const matchUserScanCodeCheck = (data: Match.ScanCode.User.Body) =>
  request<string>('/compete/user_scan_code_check', 'POST', data);
// ar打卡
export const arCheckinSuccess = (data: Match.ScanCode.Ar.Body) =>
  request<string>('/compete/user_scan_ar_check', 'POST', data);
// ar打卡跳过
export const arCheckinSkip = (data: Match.ScanCode.Ar.Body) =>
  request<string>('/compete/user_scan_ar_skip', 'POST', data);

// 查看成绩单
export const matchViewScore = (query: Partial<Match.Score.Data>) =>
  request<string>('/compete/view_score', 'GET', query);

// 个人报名
// 图片点位打卡
export const singleCompetePicPointInfo = (query: { point_id: string }) =>
  request<Match.Check.UploadImage.Data>('/single_compete/pic_point_info', 'GET', query);
// 上传图片打卡检测
export const singleCompeteSubmitPicCheck = (data: { point_id: string; img: string }) =>
  request<string>('/single_compete/submit_pic_check', 'POST', data);
// 上传图片人工打卡
export const singleCompeteSubmitPicManualCheck = (data: { point_id: string; img: string }) =>
  request<string>('/single_compete/submit_pic_manual_check', 'POST', data);

/**
 * AR打卡相关接口
 */
// 获取AR打卡点信息
export const arCheckinPointInfo = (query: { point_id: string }) =>
  request<Match.AR.PointInfo.Data>('/ar/point_info', 'GET', query);
// 提交AR打卡
export const arCheckinSubmit = (data: Match.AR.CheckinSubmit.Body) =>
  request<string>('/ar/checkin_submit', 'POST', data);
// 获取AR线索信息
export const arClueInfo = (query: { point_id: string }) =>
  request<Match.AR.ClueInfo.Data>('/ar/clue_info', 'GET', query);

/**
 * Coze相关接口
 */
export const cozeImageToImage = (data: { filePath: string }) =>
  uploadRequest<Coze.ImageToImage.Data>('/coze/imageToImage', data.filePath);
// 获取Coze生成结果
export const cozeGetResult = (data: Coze.GetResult.Body) =>
  request<Coze.GetResult.Data>('/coze/getResult', 'POST', data);
// 合成图背景列表
export const cozeGetBgPicList = (data: Coze.BgPicList.Body) => request<ResPages<Coze.BgPicList.Data[]>>('/coze/getBgPicList', 'GET', data);
// 选择背景图或者装饰图合成图
export const cozeComposeImage = (data: Coze.ComposeImage.Body) =>
  request<Coze.ImageToImage.Data>('/coze/composeImage', 'POST', data);
// 获取合成图结果
export const cozeGetComposeResult = (data: Coze.GetResult.Body) =>
  request<Coze.GetResult.Data>('/coze/getComposeResult', 'POST', data);
// 合成记录列表
export const cozeGetPicRecord = (data: ReqPages) =>
  request<Coze.GetResult.Data>('/coze/getPicRecord', 'GET', data);
// 支付获取订单号
export const cozePay = (data: Omit<SignTeam.Pay.Body, 'wx_code'>) =>
  request<WxPayInfo & { order_id: number }>('/coze/pay', 'POST', data);
// 配置
export const cozeConfig = () => request<Coze.Config.Data>('/coze/config', 'GET');
// 开场白、历史对话
export const cozeGetWelcomeText = () => request<Coze.WelcomeText.Data>('/coze/getWelcomeText', 'GET');
// 发起对话非流式
export const cozeChat = (data: Partial<Coze.Chat.Body>) => request<Coze.Chat.Data>('/coze/chat', 'POST', data);
// 发起对话流式
export const cozeChatStream = (data: Partial<Coze.Chat.Body>) =>
  request<Coze.Chat.Data>('/coze/chatStream', 'POST', data);
